package com.hh.system.action;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.hh.baseframework.util.date.DateFormat;
import com.hh.baseframework.util.document.WordUtil;
import com.hh.baseframework.util.io.FileUtil;
import com.hh.system.inf.IFileAction;
import com.hh.system.util.StaticVar;
import com.hh.system.util.base.BaseServletAction;

@SuppressWarnings("serial")
public class WordAction extends BaseServletAction implements IFileAction {
	private byte[] bytes = null;
	private String title;
	private String dataListString;

	public String exportWord() {
		if (title == null) {
			title = "test";
		}
		List<String> filePath = new ArrayList<String>();
		String pathString = StaticVar.webappPath + "/temp/";
		filePath.add(pathString);
		pathString += DateFormat.getData();
		filePath.add(pathString);
		FileUtil.isExist(filePath);
		this.setBytes(WordUtil.exportWordByte(dataListString, pathString+"/"
				+ UUID.randomUUID().toString() + ".doc"));
		return "word";
	}

	public byte[] getBytes() {
		return bytes;
	}

	public void setBytes(byte[] bytes) {
		this.bytes = bytes;
	}

	public int getContentLength() {
		return this.bytes.length;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDataListString() {
		return dataListString;
	}

	public void setDataListString(String dataListString) {
		this.dataListString = dataListString;
	}


}
